Shipping label
In this section, you will find the explanation of how to create a shipping label.
Shipping label request
To get a shipping label, you need to send a GET
request to the endpoint /api/Carriers/[CARRIER_ID]/shippingLabel
with the request body.
The path will be different depending on the output format you want. Here are the different paths:
Output format | Path |
---|---|
ZPL | /api/Carriers/[CARRIER_ID]/shippingLabel/zpl |
/api/Carriers/[CARRIER_ID]/shippingLabel/pdf |
The request body should contain the following fields:
Field | Type | Format | Description |
---|---|---|---|
trackingNumber | REQUIRED | string | The tracking number of the shipment |
ZPL
Here's an example in JavaScript of sending a request to create a shipping label in ZPL format:
- cURL
- JavaScript
curl --location --globoff --request GET 'https://alphadev-api.peddler.com/api/Carriers/[CARRIER_ID]/shippingLabel/zpl' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer RRMg2ef7jspI7Ze0NG6DjV6P8CVHJpr7' \
--data '{
"trackingNumber": "P195214835232769147"
}'
const labelBody = [
{
trackingNumber: '123456789'
},
];
fetch('https://api-lokl.peddler.com/api/Carriers/CARRIER_ID/shippingLabel/zpl', {
method: 'GET',
headers: {
'Authorization': `Bearer ${access_token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(labelBody)
})
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
PDF
Here's an example in JavaScript of sending a request to create a shipping label in PDF format:
- cURL
- JavaScript
curl --location --globoff --request GET 'https://alphadev-api.peddler.com/api/Carriers/[CARRIER_ID]/shippingLabel/pdf' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer RRMg2ef7jspI7Ze0NG6DjV6P8CVHJpr7' \
--data '{
"trackingNumber": "P195214835232769147"
}'
const labelBody = [
{
trackingNumber: '123456789'
},
];
fetch('https://api-lokl.peddler.com/api/Carriers/CARRIER_ID/shippingLabel/pdf', {
method: 'GET',
headers: {
'Authorization': `Bearer ${access_token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(labelBody)
})
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
Shipping label response
Depending on the output format, the response will be different.
ZPL
If the output format is ZPL
, the response will be a string containing the ZPL code.
HTTP/1.1 200 OK
Content-Type: text/plain
^XA^FO50,50^A0N,50,50^FD123456789^FS^XZ
HTTP/1.1 404 Not Found
Content-Type: application/json
Content-Length: 12345
{
"error": {
"statusCode": 404,
"name": "tracking-number-not-found",
"message": "TRACKING NUMBER NOT FOUND"
}
}
PDF
If the output format is PDF
, the response will be a base64 encoded string containing the PDF file.
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 12345
Content-Disposition: attachment; filename="XXXXXX1.pdf"
Content-Transfer-Encoding: base64
HTTP/1.1 404 Not Found
Content-Type: application/pdf
{
"error": {
"statusCode": 404,
"name": "tracking-number-not-found",
"message": "TRACKING NUMBER NOT FOUND"
}
}